package com.chenfan.mcn.enums;

import lombok.Getter;

/**
 * @Author liuyang
 * @Date 2021/7/19
 * @Time 10:52
 * @Version V1.0
 **/
public enum YearContractTypeEnum {

    /**
     * 年框合同类型
     */
    ADYearFrame("ADYearFrame", "广告年框"),

    StarPurhaseYearFrame("starPurhaseYearFrame", "红人采买年框"),

    LiveYearFrame("liveYearFrame", "直播年框");

    @Getter
    private final String code;

    @Getter
    private final String statusName;

    YearContractTypeEnum(String code, String statusName) {
        this.code = code;
        this.statusName = statusName;
    }

    public String code() {
        return this.code;
    }

    public static String getStatusName(String code) {
        for (YearContractTypeEnum status : YearContractTypeEnum.values()) {
            if (status.code.equals(code)) {
                return status.statusName;
            }
        }
        return null;
    }

    /** 根据状态码任意匹配
     * @param code
     * @param items
     * @return
     */
    public static boolean anyMatch(String code, YearContractTypeEnum... items) {
        boolean match = false;
        if(code != null) {
            for(YearContractTypeEnum item : items) {
                if(item.getCode().equalsIgnoreCase(code)) {
                    match = true;
                    break;
                }
            }
        }
        return match;
    }
}
